<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 777
  Date: 2021/7/3
  Time: 17:00
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>题库-编辑试题-赛事星</title>
    <link href="/Eventstar/css/book_add.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="/Eventstar/js/jquery-1.10.2.js" ></script>
</head>
<script>
    $(function (){
        var type;
        var dan;

        $(".dan").on("click",this,function () {
            if($(this).hasClass("danborder")){
                $(this).removeClass("danborder");
            }
            else{
                $(".ans").removeClass("danborder");
                $(".dan").each(function () {
                    $(this).removeClass("danborder");
                })
                $(this).addClass("danborder");
            }
            type="";
            type=$(this).html();
            console.log($(this).html())



        })
        $(".ans").on("click",this,function () {
            if(type=="单选"){
                if($(this).hasClass("danborder")){
                    $(this).removeClass("danborder");
                }
                else{
                    $(".ans").each(function () {
                        $(this).removeClass("danborder");
                    })
                    $(this).addClass("danborder");
                    dan="";
                    dan=$(this).html();
                    $(".daan").val(dan);
                }
            }else if(type=="多选"){
                dan=$(this).html();
                $(".daan").val(dan);
                $(this).toggleClass("danborder");
            }

        })

        $(".btn2").click(function (){
            if($(".timu").val()==""||$("#inpa").val()==""||$("#inpb").val()==""||$("#inpc").val()==""||$(".daan").val()==""){
                alert("添加失败，有必填项为空");
            }else {
                alert("添加成功,可继续添加");
            }
        })
    })
</script>
<body>
<img src="/Eventstar/img/book_addhead.jpg">
<div id="max">
    <div id="head"></div>
    <div id="d1">
        <form action="/Eventstar/book/book_addtimu" method="post">
            <div id="d2">
                题目：<input type="text" class="timu" name="qname" placeholder="必填"/><br /><br />
                选项：<div class="diva">A</div><input type="text" class="inpa" name="qa" placeholder="必填"/>
                <div class="divb">B</div><input type="text" class="inpb" name="qb" placeholder="必填"/>
                <div class="divc">C</div><input type="text" class="inpc" name="qc" placeholder="必填"/>
                <div class="divd">D</div><input type="text" class="inpd" name="qd"/>
                <br /><br /><br /><br /><br /><br /><br /><br />
                题型:<div class="dan">单选</div><div class="dan" id="duo">多选</div><br /><br />
                答案：<div class="ans" id="ana">A</div>
                <div class="ans" id="anb">B</div>
                <div class="ans" id="anc">C</div>
                <div class="ans" id="and">D</div>
                &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
                添加至：<select name="bookname01">
                <c:forEach items="${allbook}" var="a">
                <option>${a.bookname}</option>
                </c:forEach>
            </select>
            </div>
    </div>
    <br /><input type="text" name="bookname" value="${bookname}" style="display: none">
    <input type="text" name="daan" value="" style="display: none" class="daan">
    <button name="btn" class="btn1" value="取消">取消</button>
    <button name="btn" class="btn2" value="确定">确定</button>
    </form>
</body>
</html>
